<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >

<%@ include file="../base/taglibs.jsp" %>
<%@ page session="true"%>

<html>
	<%@ include file="../base/head.jsp" %>

	<body>
		<div id="wrap">
			<%@ include file="../snipped/header.jsp"%>
			
			<div id="content">
			
				<%-- EDITACE --%>
				<c:if test="${edit}">
				
				<form:form id="form" method="post" modelAttribute="band" action="bandSave">
					
					<%@ include file="../snipped/msgErr.jsp" %>
					<%--<form:errors path="*" /> --%>
			  		
			  		<h2><c:out value="${band.name}"/></h2>
			
					<table>
						<tr>		
							<th><form:label path="name">Název:</form:label></th>
							<td nowrap="nowrap"><form:input path="name" maxlength="50" size="50" /><small>max. 50 znaků</small></td>
							<th nowrap="nowrap"><form:label path="creation">Založení:</form:label></th>
							<td nowrap="nowrap"><form:input path="creation" /><small>vzor: RRRR-MM-DD</small></td>
						</tr>
						<tr>		
							<th><form:label path="email">Email:</form:label></th>
							<td><form:input path="email" maxlength="50" size="50" /></td>
						
							<th><form:label path="breakup">Rozpad:</form:label></th>
							<td><form:input path="breakup" /><small>vzor: RRRR-MM-DD</small></td>
						</tr>
						<tr>
							<th><form:label path="description">Popis:</form:label></th>
							<td colspan="3"><form:textarea path="description" cols="85" rows="3"/><br /><small>max. 200 znaků</small></td>
						</tr>
						<tr>
							<td></td>
							<td colspan="3">
								<button type="submit">Uložit</button><form:input path="id" cssStyle="visibility:hidden;" />
							</td>
						</tr>
					</table>
					
				</form:form>
				
				</c:if>
			
				<%-- PROHLIZENI --%>
				<c:if test="${not edit}">
				
				<h2><c:out value="${band.name}"/></h2>
			
				<table>
					<tr>
						<th>Název</th>
						<td><c:out value="${band.name}"/></td>
						<th>Datum založení</th>
						<td><c:out value="${band.creation}"/></td>
					</tr>
					<tr>
						<th>Email</th>
						<td><c:out value="${band.email}"/></td>
						<th>Datum rozpadu</th>
						<td colspan="3"><c:out value="${band.breakup}"/></td>
					</tr>
					<tr>
						<th>Popis</th>
						<td><c:out value="${band.description}"/></td>
					</tr>
				</table>
				
				</c:if>
				

				<c:if test="${edit}">				
				<p>
				<a href="<c:url value="/band/editMembers?id=${band.id}" />">&gt;&gt;&nbsp;Upravit členy</a>&nbsp;&nbsp;&nbsp;
				<a href="<c:url value="/band/editSongs?id=${band.id}" />">&gt;&gt;&nbsp;Upravit repertoár</a>&nbsp;&nbsp;&nbsp;
				<a href="<c:url value="/band/editConcerts?id=${band.id}" />">&gt;&gt;&nbsp;Upravit koncerty</a>
				</p>
				</c:if>
				
				
				<%-- START CLENOVE KAPELY --%>
				<div style="float:left;">
				
				<h3>Členové:</h3>
				<div id="tbody">
				<table width="100%">
					<tr>
						<th>Přezdívka</th>
						<th>Jméno</th>
						<th>Příjmení</th>
						<th></th>
					</tr>
					<c:forEach varStatus="stat" var="m" items="${band.members}">
					<tr class="${stat.index % 2 == 0 ? 'odd' : 'even'}">
						<td><c:out value="${m.nick}"/></td>
						<td><c:out value="${m.name}"/></td>
						<td><c:out value="${m.surname}"/></td>
						<td align="center">
							<a href="<c:url value="/member/detail?id=${m.id}" />">
								<img alt="Detail" src="<c:url value="/resources/images/browse.png" />" height="18" /></a>
							
							<c:if test="${edit}">
							<a href="<c:url value="/member/edit?id=${m.id}" />">
								<img alt="Detail" src="<c:url value="/resources/images/edit.png" />" height="18" /></a>
							</c:if>
						</td>
					</tr>
					</c:forEach>
				</table>
				</div>
				
				</div>
				<%-- KONEC CLENOVE KAPELY --%>
				
				
				<%-- START KONCERTY KAPELY --%>
				<div style="float:right;">
				
				<h3>Koncerty:</h3>
				<div id="tbody">
				<table width="100%">
					<tr style="width: 100%;">
						<th>Místo</th>
						<th>Datum</th>
						<th>Popis</th>
						<th></th>
					</tr>
					
					<c:forEach varStatus="stat" var="c" items="${band.concerts}">
					<tr class="${stat.index % 2 == 0 ? 'odd' : 'even'}">
						<td><c:out value="${c.place}"/></td>
						<td><c:out value="${c.dateTime}"/></td>
						<td><c:out value="${c.description}"/></td>
						<td align="center">
							<a href="<c:url value="/concert/detail?id=${c.id}" />">
								<img alt="Detail" src="<c:url value="/resources/images/browse.png" />" height="18" /></a>
							
							<c:if test="${edit}">
							<a href="<c:url value="/concert/edit?id=${c.id}" />">
								<img alt="Detail" src="<c:url value="/resources/images/edit.png" />" height="18" /></a>
							</c:if>
						</td>
					</tr>
					</c:forEach>
				</table>
				</div>
				
				</div>
				<%-- KONEC KONCERTY KAPELY --%>
				
				
				<%-- START REPERTOAR KAPELY --%>
				<div style="clear:both;">
				<h3>Repertoár:</h3>
				<div id="tbody" style="width:800px;">
				<table width="100%">
					<tr>
						<th>Název CS</th>
						<th>Název orig.</th>
						<th>Popis</th>
						<th>Autor</th>
						<th>Arranž</th>
						<th></th>
					</tr>
					
					<c:forEach varStatus="stat" var="s" items="${band.songs}">
					<tr class="${stat.index % 2 == 0 ? 'odd' : 'even'}">
						<td><c:out value="${s.nameCs}"/></td>
						<td><c:out value="${s.nameOriginal}"/></td>
						<td><c:out value="${s.description}"/></td>
						<td><c:out value="${s.author}"/></td>
						<td><c:out value="${s.arrange}"/></td>
						<td align="center">
							<a href="<c:url value="/song/detail?id=${s.id}" />">
								<img alt="Detail" src="<c:url value="/resources/images/browse.png" />" height="18" /></a>
								
							<c:if test="${edit}">
							<a href="<c:url value="/song/edit?id=${s.id}" />">
								<img alt="Detail" src="<c:url value="/resources/images/edit.png" />" height="18" /></a>
							</c:if>
						</td>
					</tr>
					</c:forEach>
				</table>
				</div>
				
				</div>
				<%-- KONEC REPERTOAR KAPELY --%>
			</div>
			
			<br />
			<%@ include file="../snipped/footer.jsp"%>
		</div>
	</body>
	
</html>